package org.snowin.action;

import org.apache.log4j.Logger;
import org.snowin.ext.FileHelper;
import org.snowin.utils.JsoupParserUtil;

import java.io.File;
import java.util.ArrayList;
import java.util.Properties;

public class JsouparseHtml extends JsoupParserUtil {
    private static String sp = System.getProperty("file.separator");
    private static final String ABSOLTE_CURRENT_PAHT = "user.dir";
    private static String currentPath;
    private static String rootPath = "";
    private static ArrayList<String> files;
    private Logger logger = Logger.getLogger(this.getClass());

    public static void main(String[] args) {
        setRootPath();
        File file = confirmFileExist("overview.html");

    }

    public static File confirmFileExist(String sfile) {

        File libDir = new File(rootPath + sp + "test-output" + sp + "html");
        if (libDir.exists()) {
            files = FileHelper.get_Files(libDir.getPath());
            for (int i = 0; i < files.size(); i++) {
//                System.out.println(files.get(i));
                String fileName = FileHelper.getFileName(files.get(i));
                if (fileName.trim().equals(sfile)) {
                    return new File(fileName);
                }
            }
        }
        return new File("");
    }

    public static void setRootPath() {
        File directory = new File("");
        String path = "";
        try {
//          path = directory.getAbsolutePath();
            path = System.getProperty(ABSOLTE_CURRENT_PAHT);
        } catch (Exception e) {
            e.printStackTrace();
        }
        rootPath = path;
    }


}
